<#include "../global/header.html">
    <div class="aw-container-wrap">
        <div class="aw-container aw-wecenter aw-user">
            <div class="aw-user-setting">
                <div class="tab-content clearfix">

                    <!--搜索-->
                    <div class="aw-mod">
                        <div class="aw-mod-head">
                            <h4>搜索</h4>
                        </div>
                        <form id="setting_form"  method="get" action="search">
                            <#if  error = 0>
                                <div class="alert alert-error" >
                                    <button type="button" class="close" data-dismiss="alert">×</button>
                                    <span >${errormsg!}</span></div>
                            </#if>
                            <div class="aw-mod-body aw-user-setting-layout aw-user-setting-base">

                                <div class="dropdown" style="float: right;margin-right: 625px">
                                    <button class="btn btn-default dropdown-toggle btn-info" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
                                        选择搜索模板
                                        <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                                        <!--<li role="presentation"><a role="menuitem"  tabindex="-1" onclick="insertMo();">新增</a></li>-->
                                        <!--<li role="presentation"><a role="menuitem"  tabindex="-1" onclick="updateMo();">修改</a></li>-->
                                        <!--<li role="presentation"><a role="menuitem" tabindex="-1"   onclick="dele();">删除</a></li>-->
                                        <li role="presentation"><a role="menuitem" tabindex="-1"  onclick="moban(0)" id="0">无</a></li>
                                        <#list modul as x>
                                            <li role="presentation" ><a role="menuitem" tabindex="-1" onclick="caoz(${x.id})">${x.name}</a></li>
                                        </#list>

                                    </ul>

                                    <div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" id="pand" aria-hidden="true" style="margin-top: 200px">
                                        <div class="modal-dialog modal-sm">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                                    <h4  class="modal-title">
                                                        <input type="hidden" name="hiden" id="hiden"  value="${hiden!}">
                                                        <button type="button" class="btn btn-primary" data-toggle="modal" onclick="moban(-1)" data-target=".bs-example-modal-sm">选用</button>
                                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                        <button type="button" class="btn btn-danger" data-toggle="modal "onclick="dele();" data-target=".bs-example-modal-sm">删除</button>
                                                    </h4>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <dl>
                                    <dt>&nbsp;</dt>
                                    <dd>
                                        <!--<select id="model" onchange="moban(0);" name="model">-->
                                            <!--<option value="0">无</option>-->
                                            <!--<#list modul as x>-->
                                                <!--<option value="${x.id}">${x.name}</option>-->
                                            <!--</#list>-->

                                        <!--</select>&nbsp;&nbsp;&nbsp;-->

                                        <div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                            <div class="modal-dialog">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                                        <h4  class="modal-title" id="myModalLabel">
                                                            <div style="margin-top: 5px">

                                                                <dl>
                                                                    <dt>搜索模板:</dt>
                                                                    <dd>
                                                                        <select onchange="moban(2);" id="model1">
                                                                            <option value="0">无</option>
                                                                            <#list modul as x>
                                                                                <option value="${x.id}">${x.name}</option>
                                                                            </#list>
                                                                        </select>
                                                                    </dd>
                                                                </dl>
                                                            </div>
                                                        </h4>
                                                    </div>
                                                    <div class="modal-body">
                                                        <input type="hidden"  id="hiddenId">
                                                        <dl>
                                                            <dt>模板名称:</dt>
                                                            <dd> <input type="text" name="name_d" id="name_d"  class="form-control" placeholder="模板名称"
                                                                    /></dd>
                                                        </dl>
                                                        <dl>
                                                            <dt>关&nbsp;&nbsp;键&nbsp;字:</dt>
                                                            <dd> <input type="text" name="keyword_d" id="keyword_d"  class="form-control" placeholder="多个关键字可以以空格分隔"
                                                                    /></dd>
                                                        </dl>
                                                        <dl>
                                                            <dt>搜索范围:</dt>
                                                            <dd>
                                                                <select  id="search_type_d" name="search_type_d">
                                                                    <option value="1" id="full_d">全文</option>
                                                                    <option value="0">仅标题</option>
                                                                </select>
                                                            </dd>
                                                        </dl>
                                                        <dl>
                                                            <dt>招标类型:</dt>
                                                            <dd>
                                                                <input type="radio" checked onclick="full_d(0);" name="tender_type_d" value="0" >招标信息
                                                                <input type="radio" onclick="full_d(1);" name="tender_type_d" value="1">中标信息

                                                            </dd>
                                                        </dl>
                                                        <dl>
                                                            <dt>是否过期:</dt>
                                                            <dd>
                                                                <input type="radio" checked name="isOverdue_d" onclick="isOver(0);"  value="0">全部
                                                                <input type="radio"  name="isOverdue_d" value="1" onclick="isOver(1)">未过期
                                                                <span style="font-size: 12px">（说明：信息为中标，是否过期无用）</span>
                                                            </dd>
                                                        </dl>
                                                        <dl>
                                                            <dt>公&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;司:</dt>
                                                            <dd>
                                                                <input id="search_subscriber_d" type="text" name="search_subscriber_d"  class="form-control" placeholder="招标公司/中标公司"
                                                                       value="${search_subscriber!}">
                                                            </dd>
                                                        </dl>
                                                        <dl>
                                                            <dt>资&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;质:</dt>
                                                            <dd>
                                                                <select  style="width:150px" id="qualification_d" name="qualification_d">
                                                                    <option value="0" >全部</option>
                                                                    <#list qualificationList as x>
                                                                        <option value="${x.id}" >${x.name}</option>
                                                                    </#list>
                                                                </select>
                                                            </dd>
                                                        </dl>
                                                        <dl>
                                                            <dt>地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;域:</dt>
                                                            <dd>
                                                                <select class="span3" name="location_d" id="location_d" onchange="locations();">
                                                                    <option value="0">省份</option>
                                                                    <#list locations as x>
                                                                        <option value="${x.id}">${x.name}</option>
                                                                    </#list>
                                                                </select>

                                                                <select id="location_d1" name="location_d1" >
                                                                    <option value="0">地区</option>

                                                                </select>
                                                            </dd>
                                                        </dl>
                                                        <dl>
                                                            <dt>金&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;额:</dt>
                                                            <dd>
                                                                <select style="width:150px" id="itemAmount_d" name="itemAmount_d" >
                                                                    <option value="0" >全部</option>
                                                                    <option value="1">20万以下</option>
                                                                    <option value="2">20万到50万</option>
                                                                    <option value="3">50万到100万</option>
                                                                    <option value="4">100万到300万</option>
                                                                    <option value="5">300万到600万</option>
                                                                    <option value="6">600万到1000万</option>
                                                                    <option value="7">1000万以上</option>
                                                                </select>
                                                            </dd>
                                                        </dl>


                                                    </div>

                                                    <div class="modal-footer">
                                                        (说明:当招标类型为中标时，是否过期、地域与资质无法选取！)
                                                        <button type="button" class="btn btn-success" id="xinz" onclick="sub();">新增</button>
                                                        <!--<button type="button" class="btn btn-danger" onclick="dele();">删除</button>-->
                                                        <button type="button" class="btn btn-primary" id="xiug" onclick="xiu();">修改</button>
                                                        <button type="button" class="btn btn-default" id="colo" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>


                                        </dd>
                                    </dl>
                                <dl>
                                    <dt>
                                        关&nbsp;键&nbsp;字:
                                    </dt>
                                    <dd>
                                        <input id="appendedInputButtons" type="text" name="search_key" class="form-control" placeholder="多个关键字可以以空格分隔"
                                               value="${search_key!}">
                                        搜索范围:&nbsp;
                                        <select id="search_type" name="search_type">
                                            <option value="0">仅标题</option>
                                            <option value="1" id="full">全文</option>
                                        </select>
                                    </dd>
                                </dl>
                                
                                <!--<dl>-->
                                    <!--<dt>搜索范围:</dt>-->
                                    <!--<dd>-->
                                        <!--<input type="radio" name="search_type" value="0">仅标题-->
                                        <!--<input type="radio" name="search_type" value="1">全文-->
                                    <!--</dd>-->
                                <!--</dl>-->
                                <dl>
                                    <dt>招标类型:</dt>
                                    <dd>
                                        <input type="radio" onclick="full(0);" name="tender_type" value="0">招标信息
                                        <input type="radio" onclick="full(1);" name="tender_type" value="1">中标信息
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>是否过期:</dt>
                                    <dd>
                                        <input type="radio" name="isOverdue"  value="0">全部
                                        <input type="radio" name="isOverdue"  value="1">未过期
                                        <span style="font-size: 1px">（说明：信息为中标，是否过期无用）</span>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>公&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;司:</dt>
                                    <dd>
                                        <input id="appendedInputButtons1" type="text" name="search_subscriber" class="form-control" placeholder="招标公司/中标公司"
                                               value="${search_subscriber!}">
                                    </dd>
                                </dl>

                                <dl>
                                    <dt>资&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;质:</dt>
                                    <dd>
                                        <select  style="width:150px"  id="qualification" name="qualification">
                                            <option value="0"  >全部</option>
                                            <#list qualificationList as x>
                                                <option value="${x.id}" >${x.name}</option>
                                            </#list>
                                        </select>
                                    </dd>
                                </dl>


                                    <!--<dt>地域:</dt>-->
                                    <!--<dd>-->
                                        <!--<select class="span3" name="location" id="location_id">-->
                                            <!--<option value="0">全部</option>-->
                                        <!--</select>-->
                                    <!--</dd>-->
                                    <dl>
                                        <dt>地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;域:</dt>
                                        <dd>
                                            <select class="span3"  name="location" id="location" onchange="locations1()">
                                                <option value="0">省份</option>
                                                <#list locations as x>
                                                    <option value="${x.code}">${x.name}</option>
                                                </#list>
                                            </select>
                                            <select id="location1" name="location1">
                                                <option value="0">地区</option>
                                            </select>
                                        </dd>
                                    </dl>
                                <dl>
                                    <dt>金&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;额:</dt>
                                    <dd>
                                        <select style="width:150px" id="itemAmount" name="itemAmount">
                                            <option value="0">全部</option>
                                            <option value="1">20万以下</option>
                                            <option value="2">20万到50万</option>
                                            <option value="3">50万到100万</option>
                                            <option value="4">100万到300万</option>
                                            <option value="5">300万到600万</option>
                                            <option value="6">600万到1000万</option>
                                            <option value="7">1000万以上</option>
                                        </select>
                                    </dd>
                                </dl>


                                <dl>
                                    <dt>&nbsp;</dt>
                                    <dd>
                                        <div style="float: left">
                                            <input type="submit" value="搜索" class="form-control"/>
                                        </div>
                                        <div style="float: left">
                                            &nbsp;&nbsp;&nbsp;
                                        <input type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal1" value="保存此模板"/>
                                        <div class="modal" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
                                            <div class="modal-dialog">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                        <h4 class="modal-title" id="myModalLabel1">模板保存</h4>
                                                    </div>
                                                    <div class="modal-body">
                                                        <dl>
                                                            <dt>模板名称:</dt>
                                                            <dd> <input type="text" name="name" id="name"  class="form-control" placeholder="模板名称"
                                                                    /></dd>
                                                        </dl>
                                                    </div>
                                                    <div class="modal-footer">
                                                        <button type="button" class="btn btn-primary"  onclick="add_model();">保存</button>
                                                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                            </div>
                                    </dd>
                                </dl>

                            </div>

                        </form>

                    </div>
                    <!-- 搜索结束-->
                    <div class="aw-mod">
                        <div class="aw-mod-head">
                            <h4>搜索内容</h4>
                        </div>
                        <div style="width: 1020px;height:30px;">


                        </div>
                        <div class="aw-user-setting-reset-table">
                            <table class="table table-striped table-bordered">
                                <thead>
                                <tr>
                                    <th>#</th>
                                    <th >中标项目名称
                                        <!--<a href="/search?bian=1&tender_type=1&bi=${bi!}&search_key=${search_key}&search_subscriber=${search_subscriber}&itemAmount=${itemAmount}&location=${location}"><span id="b1" class="glyphicon glyphicon-chevron-up"></span></a>-->
                                        <a onclick="wino(1)"><span id="b1" class="glyphicon glyphicon-chevron-up"></span></a>
                                    </th>
                                    <th style="width: 120px">招标编号
                                        <a onclick="wino(2)"><span id="b2" class="glyphicon glyphicon-chevron-up"></span></a>


                                    </th>
                                    <th style="width: 120px">中标公告时间
                                        <a onclick="wino(3)"><span id="b3" class="glyphicon glyphicon-chevron-up"></span></a>

                                    </th>
                                    <th style="width: 160px">中标单位</a>
                                        <a onclick="wino(4)"><span id="b4" class="glyphicon glyphicon-chevron-up"></span></a>

                                    </th>
                                    <th style="width: 100px">中标金额</a>
                                        <a onclick="wino(5)"><span id="b5"  class="glyphicon glyphicon-chevron-up"></span></a>
                                        <br/>(单位：万元)

                                    </th>
                                    <th style="width: 50px"></th>
                                </tr>
                                </thead>
                                <tbody >
                                <#list newsPage.getList() as x>
                                    <tr>
                                        <td>${x_index+1}</td>
                                        <td>
                                            <a title="${x.title}" href="${x.url}" target="_blank">${x.title_key}</a>

                                        </td>
                                        <td>${x.tender_id!}</td>
                                        <td>${x.time!}</td>
                                        <td>${x.win_bid_company!}</td>
                                        <td>
                                            <!--${x.win_bid_figure!}-->
                                            <#if x.win_bid_figure!=0>
                                                ${(x.win_bid_figure/10000)?string("#.00")}
                                            </#if>

                                        </td>
                                        <td>
                                            <a class="btn btn-sm btn-danger" href="news/result_detailsPage?id=${x.id}&keyList=${search_key!}" target="_blank">详情 </a>
                                        </td>
                                    </tr>
                                </#list>
                                </tbody>
                            </table>
                            <#include "/home/paginate.html" />

                            <@paginate currentPage=newsPage.pageNumber totalPage=newsPage.totalPage actionUrl="search?search_key=${search_key_hi!}&search_subscriber=${search_subscriber}&orderby=${orderby}&tender_type=${tender_type}&bian=${bian}&itemAmount=${itemAmount}&location=${location}&hiden=${hiden}&kou=1&p=" />

                        </div>

                    </div>


                </div>

            </div>
        </div>
        <style  type="text/css">
            .hidden{
                display: none;
            }

        </style>
        <script type="text/javascript" >
        var tender_type_d=0;
        var isOverdue_d=0;

        function caoz(id){
            $("#hiden").val(id);
            $("#pand").modal('show');
        }
        function dele(){
            var id=$("#hiden").val();
//            var model=$("#model").val();
            if(!confirm("是否删除？")){
                return;
            }else {
                $.post(
                        "search/deleteModule",
                        {id: id},
                        function (data) {
                            if (data.msg == 0) {
                                alert("删除成功！");
//                        $("#model1").val(0);
                                window.location.href = "search?tender_type=1";
                            } else if (data.msg == 1) {
                                alert("删除失败！");
                            }
                        }, "json"
                );
            }

        }
        function xiu(){
//            var model1=$("#model1").val();
            var id=$("#hiden").val();
            var name_d=$("#name").val().trim();
            var keyword_d=$("#appendedInputButtons").val();
            var search_type_d=$("#search_type").val();
            var search_subscriber_d=$("#appendedInputButtons1").val();
            var location_d=$("#location1").val();
            if(location_d==0){
                location_d=$("#location").val();
            }
            var itemAmount_d=$("#itemAmount").val();
            var qualification_d=$("#qualification").val();
            if(name_d.length>15){
                alert("模板名称过长,最高不得超过十五个字符！");

            }else if(keyword_d.length>100){
                alert("关键字过长！");
            }else if(search_subscriber_d.length>50){
                alert("公司名称过长！");
            }else if(name_d==null || name_d=="") {
                alert("模板名称不能为空！");
            }else{
                $.post(
                        "search/modul_update",
                        {id:id,name_d:name_d,keyword_d:keyword_d,search_type_d:search_type_d,tender_type_d:tender_type_d,isOverdue_d:isOverdue_d,
                            search_subscriber_d:search_subscriber_d,location_d:location_d,itemAmount_d:itemAmount_d,qualification_d:qualification_d},
                        function(data){
                            if(data.msg==1){
                                alert("修改失败!");
                            }else if(data.msg==0){
                                alert("修改成功!");
                                $("#setting_form").submit();
//                                window.location.href ="search?tender_type=1&hiden="+id;
//                        $("#model").val(data.id1);
//                        alert("123");
                            }else if(data.msg==2){
                                alert("模板名重复！");
                            }else if(data.msg==3){
                                alert("模板名称过长,最高不得超过十五个字符！");
                            }
                        },"json"
                );
            }
        }
//        function xiu(){
//            var model1=$("#model1").val();
//            var id=$("#hiddenId").val();
//            var name_d=$("#name_d").val().trim();
//            var keyword_d=$("#keyword_d").val();
//            var search_type_d=$("#search_type_d").val();
//            var search_subscriber_d=$("#search_subscriber_d").val();
//            var location_d=$("#location_d1").val();
//            if(location_d==0){
//                location_d=$("#location_d").val();
//            }
//            var itemAmount_d=$("#itemAmount_d").val();
//            var qualification_d=$("#qualification_d").val();
//            if(name_d.length>6){
//                alert("模板名称过长,最高不得超过六个字符！");
//
//            }else if(keyword_d.length>100){
//                alert("关键字过长！");
//            }else if(search_subscriber_d.length>50){
//                alert("公司名称过长！");
//            }else if(name_d==null || name_d=="") {
//                alert("模板名称不能为空！");
//            }else if(model1==0){
//                alert("该模板为无，请切换模板后在修改！");
//            }else{
//                $.post(
//                        "search/modul_update",
//                        {id:id,name_d:name_d,keyword_d:keyword_d,search_type_d:search_type_d,tender_type_d:tender_type_d,isOverdue_d:isOverdue_d,
//                            search_subscriber_d:search_subscriber_d,location_d:location_d,itemAmount_d:itemAmount_d,qualification_d:qualification_d},
//                        function(data){
//                            if(data.msg==1){
//                                alert("修改失败!");
//                            }else if(data.msg==0){
//                                alert("修改成功!");
//                                window.location.href ="search?tender_type=1&model="+id;
////                        $("#model").val(data.id1);
////                        alert("123");
//                            }else if(data.msg==2){
//                                alert("模板名重复！");
//                            }else if(data.msg==3){
//                                alert("模板名称过长,最高不得超过六个字符！");
//                            }
//                        },"json"
//                );
//            }
//        }
        function insertMo(){
            $("#name_d").prop("disabled", false);
            $("#xinz").removeClass("hidden");
            $("#xiug").addClass("hidden");
            $("#model1").val(0);
            moban(2);
            $('#myModal').modal('show')
        }
        function updateMo(){
            var id=$("#model").val();
            if(id==0){
                alert("当前模板为无，无法修改");
                $('#myModal').modal('hide')
                return;
            }else {
                $("#name_d").prop("disabled", true);
                moban(1);
                $("#xinz").addClass("hidden");
                $("#xiug").removeClass("hidden");
                $('#myModal').modal('show')
            }
        }
        function moban(id){
//            if(b==0){
//                var id=$("#model").val();
            var b;
            if(id==-1) {
                b=1;
                id = $("#hiden").val();
            }
            $("#hiden").val(id);
                $.post(
                        "search/findById",
                        {id:id},
                        function(data){
                            $("#pand").modal('hide');

//                            $("#model1").val(id);
                            var module=data.module;
                            $("#appendedInputButtons").val(module.search_key);
//                        $("#appendedInputButtons1").var(module.);
                            $("#search_type").val(module.search_type);
                            $("#qualification").val(module.qualification_id);
                            var tender_type = module.tender_type;
                            if(tender_type==1){
                                $("input[name='tender_type']:eq(1)").click();
                            }else{
                                $("input[name='tender_type']:eq(0)").click();
                            }
                            $("#itemAmount").val(module.item_amount);
                            $("#hiddenId").val(module.id);
                            var isOverdue = module.is_overdue;
                            if(isOverdue==1){
                                $("input[name='isOverdue']:eq(1)").click();
                            }else{
                                $("input[name='isOverdue']:eq(0)").click();
                            }
                            $("#search_type").val(module.search_type);
                            $("#appendedInputButtons1").val(module.search_subscriber);
//                    if(data.location==null){
//                        $("#location").val(0);
//                    }else{
//                        $("#location").val(data.location);
//                    }
                            $("#location").val(data.shen);
                            locations1(data.shi);
                            if(b==1) {
                                $("#setting_form").submit();
                            }
//                            if(data.location!=null) {
//                                if (data.location.level == 1) {
//                                    $("#location").val(data.location.id);
//                                    $("#location1").val(0);
//                                } else if (data.location.level == 2 || data.location.level == 3) {
//                                    $("#location").val(data.location.pid);
//                                    locations1(data.location.id);
//                                }
//                            }else{
//                                $("#location").val(0);
//                                $("#location1").val(0);
//                            }
                        },"json"
                );
//            }
//        else if(b==1){
//
//                var id=$("#model").val();
//                $.post(
//                        "search/findById",
//                        {id:id},
//                        function(data){
//                            var module=data.module;
////                    $("#hiddenId").val(module.id);
//                            $("#name_d").val(module.search_module_name);
////                        $("#search_type_d").val(module.search_type);
//                            $("#keyword_d").val(module.search_key);
//                            $("#qualification_d").val(module.qualification_id);
//                            var tender_type = module.tender_type;
//                            if(tender_type==1){
//                                $("input[name='tender_type_d']:eq(1)").click();
//                            }else{
//                                $("input[name='tender_type_d']:eq(0)").click();
//                            }
//                            $("#itemAmount_d").val(module.item_amount);
//
//                            var isOverdue = module.is_overdue;
//                            if(isOverdue==1){
//                                $("input[name='isOverdue_d']:eq(1)").click();
//                            }else{
//                                $("input[name='isOverdue_d']:eq(0)").click();
//                            }
//                            $("#search_type_d").val(module.search_type);
//                            $("#search_subscriber_d").val(module.search_subscriber);
////                    if(data.location==null){
////                        $("#location").val(0);
////                    }else{
////                        $("#location_d").val(data.location);
////                    }
//                            if(data.location!=null) {
//                                if (data.location.level == 1) {
//                                    $("#location_d").val(data.location.id);
//                                    locations();
//                                } else if (data.location.level == 2 || data.location.level == 3) {
//                                    $("#location_d").val(data.location.pid);
//                                    var id=data.location.id;
//                                    locations(id);
//                                }
//                            }else{
//                                $("#location_d").val(0);
//                                $("#location_d1").val(0);
//                            }
//                        },"json"
//                );
//            }else if(b==2){
//
//                var id=$("#model1").val();
//                $.post(
//                        "search/findById",
//                        {id:id},
//                        function(data){
//                            var module=data.module;
////                    $("#hiddenId").val(module.id);
//                            $("#name_d").val(module.search_module_name);
////                        $("#search_type_d").val(module.search_type);
//                            $("#keyword_d").val(module.search_key);
//                            $("#qualification_d").val(module.qualification_id);
//                            var tender_type = module.tender_type;
//                            if(tender_type==1){
//                                $("input[name='tender_type_d']:eq(1)").click();
//                            }else{
//                                $("input[name='tender_type_d']:eq(0)").click();
//                            }
//                            $("#itemAmount_d").val(module.item_amount);
//
//                            var isOverdue = module.is_overdue;
//                            if(isOverdue==1){
//                                $("input[name='isOverdue_d']:eq(1)").click();
//                            }else{
//                                $("input[name='isOverdue_d']:eq(0)").click();
//                            }
//                            $("#search_type_d").val(module.search_type);
//                            $("#search_subscriber_d").val(module.search_subscriber);
////                    if(data.location==null){
////                        $("#location").val(0);
////                    }else{
////                        $("#location_d").val(data.location);
////                    }
//                            if(data.location!=null) {
//                                if (data.location.level == 1) {
//                                    $("#location_d").val(data.location.id);
//                                    locations();
//                                } else if (data.location.level == 2 || data.location.level == 3) {
//                                    $("#location_d").val(data.location.pid);
//                                    var id=data.location.id;
//                                    locations(id);
//                                }
//                            }else{
//                                $("#location_d").val(0);
//                                $("#location_d1").val(0);
//                            }
//                        },"json"
//                );
//            }
        }
        function locations(id){

            $("#location_d1").html("");
            var location_id=$("#location_d").val();

//        $("#location_id").append("<select name='location_id1' style='width: 100px' id='location_id1'></select>");
            document.getElementById("location_d1").options[0] = new Option("地区",0);
            if(location_id!=0) {
                $.post(
                        "user_district/findDis",
                        {location_id: location_id},
                        function (data) {
                            var data1 = data.list;
                            for (var i = 0; i < data1.length; i++) {
                                document.getElementById("location_d1").options[i+1] = new Option(data1[i].name, data1[i].id);
                            }
//                    alert(id);
                            if(id>0 ) {
                                $("#location_d1").val(id);
                            }
                        }, "json"
                );
            }
        }
        function add_model(){
            var name_d=$("#name").val().trim();
            var keyword_d=$("#appendedInputButtons").val();
            var search_type_d=$("#search_type").val();
            var search_subscriber_d=$("#appendedInputButtons1").val();
            var location_d=$("#location1").val();
            if(location_d==0) {
                location_d = $("#location").val();
            }
            var itemAmount_d=$("#itemAmount").val();
            var qualification_d=$("#qualification").val();
            if(name_d.length>15) {
                alert("模板名称过长,最高不得超过十五个字符！");
            }else if(name_d==null || name_d=="") {
                alert("模板名称不能为空！");
            }else {
                $.post(
                        "search/modul_add",
                        {name_d: name_d, keyword_d: keyword_d, search_type_d: search_type_d, tender_type_d: tender_type_d, isOverdue_d: isOverdue_d,
                            search_subscriber_d: search_subscriber_d, location_d: location_d, itemAmount_d: itemAmount_d, qualification_d: qualification_d},
                        function (data) {
                            if (data.msg == 1) {

                                if(confirm("模板名重复，是否需要修改?")) {
                                    xiu();
                                }
                            } else if (data.msg == 0) {
                                alert("添加成功!");
                                $("#hiden").val(data.id1);
                               $("#setting_form").submit();
//                                window.location.href ="search?tender_type=1&hiden="+data.id1;
//                                $("#model").val(data.id1);
                            }else if(data.msg==2){
                                alert("未知错误!");
                            }else if(data.msg==3){
                                alert("模板名称过长,最高不得超过十五个字符！");
                            }
                        }, "json"
                );

            }
        }

        function sub(){
            var name_d=$("#name_d").val().trim();
            var keyword_d=$("#keyword_d").val();
            var search_type_d=$("#search_type_d").val();
            var search_subscriber_d=$("#search_subscriber_d").val();
            var location_d=$("#location_d1").val();
            if(location_d==0) {
                location_d = $("#location_d").val();
            }
            var itemAmount_d=$("#itemAmount_d").val();
            var qualification_d=$("#qualification_d").val();
            alert(tender_type_d);
            if(name_d.length>15) {
                alert("模板名称过长,最高不得超过十五个字符！");
            }else if(name_d==null || name_d=="") {
                alert("模板名称不能为空！");
            }else {
                $.post(
                        "search/modul_add",
                        {name_d: name_d, keyword_d: keyword_d, search_type_d: search_type_d, tender_type_d: tender_type_d, isOverdue_d: isOverdue_d,
                            search_subscriber_d: search_subscriber_d, location_d: location_d, itemAmount_d: itemAmount_d, qualification_d: qualification_d},
                        function (data) {
                            if (data.msg == 1) {
                                alert("模板名重复!");
                            } else if (data.msg == 0) {
                                alert("添加成功!");
                                window.location.href ="search?tender_type=1&model="+data.id1;
                                $("#model").val(data.id1);
                            }else if(data.msg==2){
                                alert("未知错误!");
                            }else if(data.msg==3){
                                alert("模板名称过长,最高不得超过十五个字符！");
                            }
                        }, "json"
                );

            }

        }
        function full_d(a){
            tender_type_d=a;
            if(a==0){
                $("[name=isOverdue_d]").prop("disabled",false);
                $("#full_d").prop("disabled", false);
                $("#qualification_d").prop("disabled", false);
                $("#location_d").prop("disabled", false);
                $("#location_d1").prop("disabled", false);

            }else{
                $("[name=isOverdue_d]").prop("disabled",true)
                $("#search_type_d").val(0);
                $("#full_d").prop("disabled", true);
                $("#qualification_d").prop("disabled", true);
                $("#qualification_d").val(0);
                $("#location_d").prop("disabled", true);
                $("#location_d").val(0);
                $("#location_d1").prop("disabled", true);
                $("#location_d1").val(0);

            }
        }

            function locations1(){
                $("#location1").html("");
                var location_id=$("#location").val();
                document.getElementById("location1").options[0] = new Option("地区",0);
//        $("#location_id").append("<select name='location_id1' style='width: 100px' id='location_id1'></select>");
                if(location_id!=0) {
                    $.post(
                            "user_district/findDis",
                            {location_id: location_id},
                            function (data) {
                                var data1 = data.list;
                                for (var i = 0; i < data1.length; i++) {
                                    document.getElementById("location1").options[i+1] = new Option(data1[i].name, data1[i].code);
                                }
                                if(id>0 ) {
                                    $("#location1").val(id);
                                }
                            }, "json"
                    );
                }
            }
            function full(a){
                tender_type_d=a;
//                 alert("123");
                if(a==0){
                    $("[name=isOverdue]").prop("disabled",false);
                    $("#full").prop("disabled", false);
                    $("#qualification").prop("disabled", false);
                    $("#location").prop("disabled", false);
                    $("#location1").prop("disabled", false);
                }else{
                    $("[name=isOverdue]").prop("disabled",true);
                    $("#search_type").val(0);
                    $("#full").prop("disabled", true);
                    $("#qualification").prop("disabled", true);
                    $("#location").prop("disabled", true);
                    $("#location1").prop("disabled", true);
                    $("#qualification").val(0);
                    $("#location").val(0);
                    $("#location1").val(0);
                }

            }

            $(function(){
//                $("[name=isOverdue]").prop("disabled",true);
//                $("#full").prop("disabled", false);
                var id1=$("#hiden").val();
                if(id1 !=0){
                    moban(id1);
                }
                var b='${bi!}';


                if(b==1){
                    $("#b1").removeClass("glyphicon glyphicon-chevron-up");
                    $("#b1").addClass("glyphicon glyphicon-chevron-down");
                }else{
                    $("#b1").removeClass("glyphicon glyphicon-chevron-down");
                    $("#b1").addClass("glyphicon glyphicon-chevron-up");
                }
                if(b==2){
                    $("#b2").removeClass("glyphicon glyphicon-chevron-up");
                    $("#b2").addClass("glyphicon glyphicon-chevron-down");
                }else{
                    $("#b2").removeClass("glyphicon glyphicon-chevron-down");
                    $("#b2").addClass("glyphicon glyphicon-chevron-up");
                }
                if(b==3){
                    $("#b3").removeClass("glyphicon glyphicon-chevron-up");
                    $("#b3").addClass("glyphicon glyphicon-chevron-down");
                }else{
                    $("#b3").removeClass("glyphicon glyphicon-chevron-down");
                    $("#b3").addClass("glyphicon glyphicon-chevron-up");
                }
                if(b==4){
                    $("#b4").removeClass("glyphicon glyphicon-chevron-up");
                    $("#b4").addClass("glyphicon glyphicon-chevron-down");
                }else{
                    $("#b4").removeClass("glyphicon glyphicon-chevron-down");
                    $("#b4").addClass("glyphicon glyphicon-chevron-up");
                }
                if(b==5){
                    $("#b5").removeClass("glyphicon glyphicon-chevron-up");
                    $("#b5").addClass("glyphicon glyphicon-chevron-down");
                }else{
                    $("#b5").removeClass("glyphicon glyphicon-chevron-down");
                    $("#b5").addClass("glyphicon glyphicon-chevron-up");
                }
                $("#itemAmount").val('${itemAmount}');
                var tender_type = '${tender_type}';
                if(tender_type==1){
                    $("input[name='tender_type']:eq(1)").click();
                }else{
                    $("input[name='tender_type']:eq(0)").click();
                }
//                var orderby = '${orderby}';
//                if(orderby==1){
//                    $("input[name='orderby']:eq(0)").click();
//                }else{
//                    $("input[name='orderby']:eq(1)").click();
//                }
                $("#location").val('${shen!}');
                locations1('${shi!}');
//                var loc='${loca!}';
//                if(loc!=null ||loc!='' ) {
//                    if ( '${loca_level!}' == 1) {
//                        $("#location").val('${loca_id!}');
//                        $("#location1").html("");
//                    } else if ('${loca_level!}'  == 2 ||'${loca_level!}'  == 3) {
//                        $("#location").val('${loca_pid!}');
//                        locations1();
//                        $("#location1").val('${loca_id!}');
//                    }
//                }else{
//                    $("#location").val(-1);
//                    $("#location1").html("");
//                }

            });
        function wino(a){
            window.location.href="/search?bian="+a+"&tender_type=1&bi=${bi!}&search_key=${search_key_hi}&search_subscriber=${search_subscriber}&itemAmount=${itemAmount}&location=${location}";
        }
        </script>
    </div>
    <#include "../global/footer.html">